package com.iona.json.builders;

import java.util.List;

import com.iona.domain.Discipline;
import com.iona.json.JSONArray;
import com.iona.json.JSONBuilder;
import com.iona.json.JSONException;

public class DisciplineBuilder extends JSONBuilder {
	private List<Discipline> disciplines;

	public DisciplineBuilder(List<Discipline> disciplines) {
		this.disciplines = disciplines;
	}

	@Override
	public Object build() throws JSONException {
		JSONArray root = new JSONArray();
		for (Discipline d : disciplines) {
			JSONArray arr = new JSONArray();
			arr.put(d.getId());
			arr.put(d.getName());
			root.put(arr);
		}

		return root;
	}

	@Override
	public String name() {
		return DisciplineBuilder.class.getSimpleName();
	}

}
